﻿




new Vue({
    el: "#app",
    data: {
        model: {
            Account: "",
            PassWord: "",
            Name: "",
            Pic: "",
            Sex: 0,
            SysRole_ID: 0,
            DisabledState: 0,
        },
        validation: {
            required: [
                'Account',
                'PassWord',
                'Name',
                'Pic',
                'Sex',
                'SysRole_ID',
                'DisabledState',
            ]
        },
        fileHeader: [
            {
                key: "1",
                name: "在线管理",
            },
            {
                key: "2",
                name: "文件上传",
            }
        ],
        fileDir: [
            {
                key: "1",
                name: "商城",
            },
            {
                key: "2",
                name: "首页广告",
            },
            {
                key: "3",
                name: "挪车码",
            },
            {
                key: "4",
                name: "挪车贴",
            }
        ],
        fileDirSelected:"",
        fileHeaderSelected:""
    },
    methods: {
        submit() {
            let _this = this;
            let validResult = _this.$refs.form.valid();
            if (!validResult.result) {
                return;
            }
            if (_this.model.ParentId == null) {
                _this.model.ParentId = 0;
            }

            var url = "SysUser//insert";
            if (_this.model.id > 0) {
                url = "SysUser//update";
            }
            $http.insertOrUpdate(url, _this.model);
        },
        loadModelData() {
            var id = this.model.id;
            if (id <= 0) {
                return;
            }
            var _this = this;
            $http.post("SysUser//singleData", { ID: id }, function (data) {
                _this.model = data;
            })
        }
    },
    mounted() {
        var id = this.$url.query("id");
        if (id != "") {
            this.model.id = id;
        }
        this.loadModelData();
    },
})